#-*-coding:utf-8-*-
import time
# 装饰器

def calRunTime(func):
	def wrapper(*args,**kwargs):
		sTime  = time.time()
		ret = func(*args,**kwargs)
		eTime = time.time()

		print " {} spend time {}".format(func.__name__,int(eTime-sTime))
		return ret

	return wrapper

@calRunTime
def add(x,y):
	return x+y


def warpper1(func):
	def inner(*args,**kwargs):
		print  "warpper1 before {} called ".format(func.__name__)
		ret = func(*args,**kwargs)
		print "warpper1 after {} called ".format(func.__name__)
		return ret
	return inner

def warpper2(func):
	def inner(*args,**kwargs):
		print  "warpper2 before {} called ".format(func.__name__)
		ret = func(*args,**kwargs)
		print "warpper2  after {} called ".format(func.__name__)
		return ret
	return inner


def warpper3(func):
	def inner(*args,**kwargs):
		print  "warpper3 before {} called ".format(func.__name__)
		ret = func(*args,**kwargs)
		print "warpper3  after {} called ".format(func.__name__)
		return ret
	return inner


@warpper3
@warpper2
@warpper1
def newAdd(x,y):
	return x,y


if __name__ == "__main__":
	pass
	# func = calRunTime(add)
	# print func(10,12)
	#print add(10,12)
	print newAdd(10,12)